API: wayland: Add gdk_wayland_window_new_subsurface()
authorBenjamin Otte <otte@redhat.com>
Sun, 6 Nov 2016 20:36:43 +0000 (21:36 +0100)
committerBenjamin Otte <otte@redhat.com>
Sun, 6 Nov 2016 20:36:43 +0000 (21:36 +0100)
... and use it instead of gdk_window_new().

docs/reference/gdk/gdk4-sections.txt
gdk/wayland/gdkwaylandwindow.h
gdk/wayland/gdkwindow-wayland.c
gtk/gtkwindow.c

index 12a569351e497d898675bcedb816b6ee9d76dd6e..65d7e138f455efae9460cfa725b99179cd85a1a8 100644 (file)
@@ -1174,6 +1174,7 @@ gdk_wayland_device_get_wl_seat
 gdk_wayland_display_get_wl_compositor
 gdk_wayland_display_get_wl_display
 gdk_wayland_display_get_xdg_shell
+gdk_wayland_window_new_subsurface
 gdk_wayland_window_get_wl_surface
 gdk_wayland_window_set_use_custom_surface
 GdkWaylandWindowExported
index 566d40524c40e16676efd5925a3992cd549b1731..628204ff4a2c2fe8437f502d8be81b1d45227952 100644 (file)
@@ -45,6 +45,10 @@ typedef struct _GdkWaylandWindowClass GdkWaylandWindowClass;
 GDK_AVAILABLE_IN_ALL
 GType                    gdk_wayland_window_get_type             (void);
 
+GDK_AVAILABLE_IN_3_90
+GdkWindow *              gdk_wayland_window_new_subsurface       (GdkDisplay            *display,
+                                                                  int                    event_mask,
+                                                                  const GdkRectangle    *position);
 GDK_AVAILABLE_IN_ALL
 struct wl_surface       *gdk_wayland_window_get_wl_surface       (GdkWindow *window);
 
index 837fde9c8c3c5bf566236efbcd0a6817c3ce9d0b..d8e1ec5efaf627d8d5e3da8f0565491410583ccc 100644 (file)
@@ -3672,6 +3672,41 @@ _gdk_wayland_window_set_grab_seat (GdkWindow *window,
   impl->grab_input_seat = seat;
 }
 
+/**
+ * gdk_wayland_window_new_subsurface: (constructor)
+ * @display: the display to create the window on
+ * @event_mask: event mask (see gdk_window_set_events())
+ * @position: position relative to the transient window
+ *
+ * Creates a new subsurface window.
+ *
+ * Returns: (transfer full): the new #GdkWindow
+ *
+ * Since: 3.90
+ **/
+GdkWindow *
+gdk_wayland_window_new_subsurface (GdkDisplay         *display,
+                                   int                 event_mask,
+                                   const GdkRectangle *position)
+{
+  GdkWindowAttr attr;
+
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+  g_return_val_if_fail (position != NULL, NULL);
+
+  attr.event_mask = event_mask;
+  attr.wclass = GDK_INPUT_OUTPUT;
+  attr.x = position->x;
+  attr.y = position->y;
+  attr.width = position->width;
+  attr.height = position->height;
+  attr.window_type = GDK_WINDOW_SUBSURFACE;
+
+  return gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (display)),
+                         &attr,
+                         GDK_WA_X | GDK_WA_Y);
+}
+
 /**
  * gdk_wayland_window_get_wl_surface:
  * @window: (type GdkWaylandWindow): a #GdkWindow
index 7cb88d7893f2c15392b623fa97f261c0e232227a..764cbf5ff7c8ddbc3194af6f9ed34f8a818a8150 100644 (file)
@@ -6370,21 +6370,10 @@ popover_realize (GtkWidget        *widget,
 #ifdef GDK_WINDOWING_WAYLAND
   if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
     {
-      GdkWindowAttr attributes;
-      gint attributes_mask;
-
-      attributes.window_type = GDK_WINDOW_SUBSURFACE;
-      attributes.wclass = GDK_INPUT_OUTPUT;
-      attributes.x = rect.x;
-      attributes.y = rect.y;
-      attributes.width = rect.width;
-      attributes.height = rect.height;
-      attributes.event_mask = gtk_widget_get_events (popover->widget) |
-        GDK_EXPOSURE_MASK;
-      attributes_mask = GDK_WA_X | GDK_WA_Y;
-
-      popover->window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)),
-                                        &attributes, attributes_mask);
+      popover->window = gdk_wayland_window_new_subsurface (gtk_widget_get_display (GTK_WIDGET (window)),
+                                                           gtk_widget_get_events (popover->widget)
+                                                           | GDK_EXPOSURE_MASK,
+                                                           &rect);
       gdk_window_set_transient_for (popover->window,
                                     _gtk_widget_get_window (GTK_WIDGET (window)));
     }
@@ -6973,12 +6962,18 @@ gtk_window_realize (GtkWidget *widget)
 #ifdef GDK_WINDOWING_WAYLAND
           if (priv->use_subsurface &&
               GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
-            attributes.window_type = GDK_WINDOW_SUBSURFACE;
+            {
+              gdk_window = gdk_wayland_window_new_subsurface (gtk_widget_get_display (widget),
+                                                              attributes.event_mask,
+                                                              &allocation);
+            }
           else
 #endif
-            attributes.window_type = GDK_WINDOW_TEMP;
-          gdk_window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)),
-                                       &attributes, 0);
+            {
+              attributes.window_type = GDK_WINDOW_TEMP;
+              gdk_window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)),
+                                           &attributes, 0);
+            }
           break;
         default:
           g_warning (G_STRLOC": Unknown window type %d!", priv->type);